package com.fyx.controller;

import com.fyx.annotation.Log;
import com.fyx.entity.*;
import com.fyx.service.IPeakService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "峰值分析")
@RestController
@RequestMapping("/api/peak")
@RequiredArgsConstructor
public class PeakController {
    @Autowired
    private IPeakService iPeakService;

    @Log("查询活跃用户峰值")
    @ApiOperation("查询活跃用户峰值")
    @GetMapping(value="activeUser")
    @PreAuthorize("@el.check('activeUser:list')")
    public Map activeUser(OnlineUserPeakEntity onlineUserPeakEntity, Pageable pageable){
        Map mapResult = iPeakService.activeUser(onlineUserPeakEntity,pageable);
        return mapResult;
    }

    @Log("查询注册用户峰值")
    @ApiOperation("查询注册用户峰值")
    @GetMapping(value="addUser")
    @PreAuthorize("@el.check('addUser:list')")
    public Map addUser(AddUserPeakEntity addUserPeakEntity, Pageable pageable){
        Map mapResult = iPeakService.addUser(addUserPeakEntity,pageable);
        return mapResult;
    }

    @Log("查询活跃用户峰值")
    @ApiOperation("查询活跃用户峰值")
    @GetMapping(value="onlineUserPeak")
    @PreAuthorize("@el.check('onlineUserPeak:list')")
    public Map onlineUserPeak(ActiveUserEntity activeUserEntity, Pageable pageable){
        Map mapResult = iPeakService.onlineUserPeak(activeUserEntity,pageable);
        return mapResult;
    }

    @Log("查询付费用户峰值")
    @ApiOperation("查询付费用户峰值")
    @GetMapping(value = "payUser")
    @PreAuthorize("@el.check('payUser:list')")
    public Map payUser(PayUserEntity payUserEntity, Pageable pageable){
        Map mapResult = iPeakService.payUser(payUserEntity,pageable);
        return mapResult;
    }

    @Log("查询充值人数峰值")
    @ApiOperation("查询充值人数峰值")
    @GetMapping(value="rechargeUser")
    @PreAuthorize("@el.check('rechargeUser:list')")
    public Map rechargeUser(RechargeUserPeakEntity rechargeUserPeakEntity, Pageable pageable){
        Map mapResult = iPeakService.rechargeUser(rechargeUserPeakEntity,pageable);
        return mapResult;
    }

    @Log("查询充值次数峰值")
    @ApiOperation("查询充值次数峰值")
    @GetMapping(value="rechargeCount")
    @PreAuthorize("@el.check('rechargeCount:list')")
    public Map rechargeCount(RechargeCountPeakEntity rechargeCountPeakEntity, Pageable pageable){
        Map mapResult = iPeakService.rechargeCount(rechargeCountPeakEntity,pageable);
        return mapResult;
    }
}
